# -*- coding: utf-8 -*-
# @Time    : 2020/8/21 13:42
# @Author  : Leo
# @FileName: wechat_email_handler.py
# @Software: PyCharm

import tornado.web
from modules.user.user_manage import UserManager
from handlers.base_handler import BaseHandler

class WechatEmailHandler(tornado.web.RequestHandler):
    """
    """

    def set_default_headers(self):
        self.set_header('Access-Control-Allow-Origin', '*')
        self.set_header('Access-Control-Allow-Headers', '*')
        self.set_header('Access-Control-Max-Age', 1000)
        # self.set_header('Content-type', 'application/json')
        self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS')
        self.set_header('Access-Control-Allow-Headers',  # '*')
                        'authorization, Authorization, Content-Type, Access-Control-Allow-Origin, Access-Control-Allow-Headers, X-Requested-By, Access-Control-Allow-Methods')

    def options(self, loginName):
        pass

    def post(self, user_id):
        """
        发送微信绑定邮件
        """
        UserManager().send_wechat_email(user_id)
        self.write({"code":200})
